/**
 * Copyright (c) 2009 blurredVision
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or 
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 
 * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
#ifndef __GUI_FRAME_H__
#define __GUI_FRAME_H__

#pragma once

#include "Component.h"
#include "Canvas.h"
#include <vector>

namespace gui {

/**
 * \ingroup coreGUI
 *
 * The Frame class <br>
 * A Frame is a container for Canvas components. <br>
 * It can hold multiple canvases that are displayed as tabs.
 * 
 * \date 04-14-2007
 *
 * \author juckel
 * 
 * \todo Hide frame contents?
 *
 */
class GUI_EXPORT Frame :
	public Component
{
public:
	//Frame(bool draggable = true);
	Frame(const std::string &title = "", bool draggable = true);
	virtual ~Frame(void);

	/** Adds a new canvas to the frame
	 * \param canvas A canvas to add. */
	void addCanvas(Canvas* canvas);

	/** Removes a canvas from the frame and returns it. 
	 * \param canvas A canvas to remove. */
	void removeCanvas(Canvas* canvas);

	/// Set the active tab to the tabIndex
	bool setActiveTab(unsigned int tabIndex);

	/// Indicates if the frame can be dragged. 
	const bool isDraggable() const;

	/// Draw the frame
	virtual void draw();

	/// Process mouse movement
	bool processMouse(int _x, int _y, int _z, int _button);

	/// Return the type of the gui element
	virtual inline const int getGUIType() const { return GUI_FRAME; }

	void setFont(IFont* pFont);
protected:
	virtual void onMousePressed(const MouseEvent &me);
	virtual void onMouseReleased(const MouseEvent &me);

	std::string    m_sTitle;
	bool           m_bOpen;
	bool           m_bDraggable;
	int            m_iDragBarSize;
	bool           m_bDragging;
	math::Vector2i vDragOffset;
	unsigned int   m_uiActiveTab;
};

} // namespace

#endif
